package com.ruoyi.back.service.impl

import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.back.domain.ImageTextShare
import com.ruoyi.back.mapper.ImageTextShareMapper
import com.ruoyi.back.service.ImageTextShareService
import org.springframework.stereotype.Service

@Service
class ImageTextShareServiceImpl : ServiceImpl<ImageTextShareMapper, ImageTextShare>(), ImageTextShareService {


    override fun saveImageTextShare(imageTextShare: ImageTextShare): Data<Boolean> =
        imageTextShare.id?.run {
            Ok("更新文案链接成功", updateById(imageTextShare))
        } ?: Ok("保存文案链接成功", save(imageTextShare))

    override fun getImageTextShare(): Data<ImageTextShare> = Ok(
        "获取文案链接成功", getOne(
            KtQueryWrapper(ImageTextShare::class.java)
        )
    )
}